import React,{Component} from 'react';
import {Text,View} from 'react-native';
import ToDoInput from './todoinput'
import ToDoList from './todolist'

export default class ToDoBox extends Component{
  
  constructor(){
    super();
    this.state = {list:[]}
  }

  save=(msg)=>{
    //msg就是子传来的数据
    var nowList = this.state.list;
    nowList.push(msg);
    this.setState({list:nowList},function(){
      //状态设置成功之后的回调函数
      console.log(this.state.list);
    });
  }

  render(){
    return <View>
        <ToDoInput funcSave={this.save}></ToDoInput>
        <Text>{'\n'}</Text>
        <ToDoList 
        myList={this.state.list}></ToDoList>
      </View>
  }
}